package services;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Set;

import sun.security.krb5.internal.PAData;

import businessEntities.*;

public class BusinessServices implements Itf_BusinessServices {

	public static final double[] QVALUE = { (double) 0.5, (double) 1,
			(double) 2, (double) 3, (double) 4, (double) 5, (double) 6,
			(double) 7, (double) 8, (double) 9, (double) 10 };
	public HashMap<Integer, Double> listeVariations = new HashMap<Integer, Double>();
	public ArrayList<Integer> lDeltaT;

	public BusinessServices() {

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * services.Itf_BusinessServices#creerTableauGraphiquePartition(businessEntities
	 * .Actif, long, int, int)
	 */
	public HashMap<Integer, Double> creerTableauCourbePartition(Actif actif,
			double q, int type1, int type2) {

		System.out.println("creerTableauCourbePartition: actif: " + actif
				+ " -  q: " + q + " - type1: " + type1 + " - type2: " + type2);
		listeVariations = new HashMap<Integer, Double>();
		lDeltaT = new ArrayList<Integer>();
		int periodeT = DateCours.getPeriodeJours(actif.getDateDebut(),
				actif.getDateFin());

		System.out.println("actif.getDateDebut(): " + actif.getDateDebut()
				+ " - actif.getDateFin() : " + actif.getDateFin());
		System.out.println("periodetT: " + periodeT);

		// for(int i=2;i<=periodeT; i=i*2){
		for (int i = 8; i <= 512; i *= 2) {
			lDeltaT.add(i);
		}

		System.out.println("lDeltaT.size(): " + lDeltaT.size());

		for (Integer deltaT : lDeltaT) {
			Double temp = actif.fonctionPartition(deltaT, q, type1, type2);
			if (temp != 0)
				listeVariations.put(deltaT, temp);
		}

		System.out
				.println("Fin creerTableauCourbePartition: return listVariation - size: "
						+ listeVariations.size());
		return listeVariations;
	}

}
